#include <stdio.h>


int main(int argc, char const *argv[])
{
    int numa = 0, numb = 0, numc = 0;
    char buffer[64] = "10-20-30";

    FILE * fp = fopen("test.txt", "r");
    // 会从文件中获取指定的格式的数值赋值到指定变量中    
    fscanf(fp, "%d-%d-%d", &numa, &numb, &numc);
    printf("numa = %d, numb = %d, numc = %d \n", numa, numb, numc);

    numa = 0, numb = 0, numc = 0;

    //从字符串缓冲区中获取数值
    sscanf(buffer, "%d-%d-%d", &numa, &numb, &numc);
    printf("numa = %d, numb = %d, numc = %d \n", numa, numb, numc);
    fclose(fp);
    return 0;
}
